<?php

use yii\grid\GridView;
use yii\widgets\Pjax;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\AuthItemSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '权限选择';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="auth-item-list">

    <?php Pjax::begin(); ?>
    <?= GridView::widget([
        'layout' => "{items}\n{pager}",
        'tableOptions' => ['class' => 'table table-hover table-bordered'],
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            ['class' => 'yii\grid\CheckboxColumn'],
            //['class' => 'yii\grid\SerialColumn'],

            [
                'attribute' => 'name',
                'label' => '权限'
            ],
            'description:ntext',
        ],
    ]); ?>
    <?php Pjax::end(); ?>

</div>

<style>
body{background-color: white}
</style>
    
<script>
<?php $this->beginBlock('auth-item-list-js') ?>
// 选择变更时，把已选中的保存到 window.dialogResult
$('.auth-item-list :checkbox').on('change',()=>{
    window.dialogResult = $('.auth-item-list tbody :checked').map(function(){
        return this.value;
    }).get();
});
<?php $this->endBlock(); ?>
<?php $this->registerJs($this->blocks['auth-item-list-js']);?>
</script>

